package com.zhny.protocol_v3_008.constant;

public enum DTypeCode {
    GATEWAY("网关",401),
    BASE("基地",402),
    AUTO_DATA_SITE("自动数据站点",403),
    ARTIFICAL_DATA_SITE("人工数据站点",404),
    CONTROL_DEVICE("控制设备",405),
    CAMERA("摄像机",406),
    ORCHARD_WEATHER_STATION("果园气象站",407),
    ORCHARD_SOIL_MOISTURE_STATION("果园土壤墒情站",408),
    DEAJEON_WEATHER_STATION("大田气象站",409),
    DEAJEON_SOIL_MOISTURE_STATION("大田土壤墒情站",410),
    VEGETABLE_GREENHOUSES("蔬菜大棚",411),
    EDIBLE_GREENHOUSES("食用菌大棚",412);

    private String name;
    private int code;

    private DTypeCode(String name, int code) {
        this.name = name;
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public int getCode() {
        return code;
    }

    public static String getName(int code) {
        if(code == 201) return "响应成功";
        for(DTypeCode rc : DTypeCode.values()) {
            if(rc.code == code)
                return rc.getName();
        }
        return null;
    }
}
